﻿using InnovaApp.Layers.DataLayer;
using InnovaApp.Layers.DomainLayer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;

namespace InnovaApp.Portals.MVC4Portal.Filters
{
    //public class LocalizeAttribute : ActionFilterAttribute
    //{
    //    private string eMethodBase = "InnovaApp.Portals.MVC4Portal.Filters.LocalizeAttribute.";

    //    public override void OnActionExecuting(ActionExecutingContext filterContext)
    //    {
    //        string eMethod = eMethodBase + "[override]OnActionExecuting";
    //        object eParameters = new { filterContext = filterContext };

    //        var user = Membership.GetUser();
    //        if (user != null)
    //        {
    //            using (DataRepositories _dataContext = new DataRepositories())
    //            {
    //                Contact dbContact = _dataContext.Contact_Rep.Query(x => x.FK_InnoAppUser == (Guid)user.ProviderUserKey).FirstOrDefault();
    //                if (dbContact == null)
    //                {
    //                    throw new INNOVACALL.Framework.Common.InnovacallExceptions.IdentificationException(eMethod, eParameters, "No contact associated to user");
    //                }
    //                INNOVACALL.Framework.Common.MVCHelpers.Localization.CommonLocalization.SetCurrentThreadLanguage(dbContact.Language.Description);
    //            }
    //        }

    //        base.OnActionExecuting(filterContext);
    //    }
    //}
}